<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0">
    <title>编辑店铺信息 - 钢域云贸</title>
    <link rel="icon" href="/uploads/logo.png" type="image/x-icon"/>
    <link rel="shortcut icon" href="/uploads/logo.png" type="image/x-icon"/>
    <link rel="stylesheet" href="/css/bootstrap.min.css" type="text/css" media="all"/>
    <link rel="stylesheet" type="text/css" href="/css/public.css"/>
    <link rel="stylesheet" type="text/css" href="/css/style.css"/>
    <script src="https://cdn.tailwindcss.com"></script>
    <style>
        /* 表单样式优化 */
        .form-label {
            font-weight: 500;
            color: #4b5563;
        }
        .form-input {
            transition: all 0.2s ease-in-out;
        }
        .form-input:focus {
            border-color: #3b82f6;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
        }
        /* 主内容区域样式 */
        main {
            display: flex;
            min-height: calc(100vh - 64px - 64px); /* 减去 header 和 footer 高度（假设各 64px） */
            width: 100%;
        }
        /* 侧边栏样式 */
        .sidebar {
            width: 256px; /* 保持当前宽度 */
            background-color: #fff;
            box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
            display: flex;
            flex-direction: column;
        }
        /* 内容区域样式 */
        .content-area {
            flex: 1;
            padding: 2rem;
            background-color: #f7fafc; /* 匹配背景色 */
        }
        /* 确保侧边栏内容区自适应 */
        .sidebar nav {
            flex-grow: 1;
        }
        /* 响应式布局 */
        @media (max-width: 640px) {
            .sidebar {
                display: none;
            }
            .content-area {
                padding: 1rem;
            }
        }
    </style>
</head>
<body class="bg-gray-100 min-h-screen">
<!-- 公共头部 -->
<th:block th:replace="~{/header.html}"></th:block>
<!-- Main Content -->
<main>
    <!-- 侧边栏 -->
    <th:block th:replace="~{/supplier/sidebar.html}"></th:block>
<!--<main class="content-with-sidebar">-->
    <!-- 内容区域 -->
    <div class="content-area">
<!--        <h1 class="text-2xl font-bold mb-6 text-gray-800">编辑店铺信息</h1>-->

        <!-- 成功提示 -->
        <div th:if="${param.success}" class="bg-green-100 border-l-4 border-green-500 text-green-700 p-4 mb-6">
            <p>店铺信息修改成功！</p>
        </div>

        <!-- 表单区域 -->
        <form th:action="@{/supplier/profile/update}" method="post" enctype="multipart/form-data" th:object="${user}"
                               class="bg-white p-8 rounded-xl shadow space-y-6 max-w-3xl mx-auto">

        <!-- 用户名（只读） -->
        <div>
            <label for="username" class="block text-gray-700 font-medium mb-2">用户名</label>
            <input type="text" id="username" th:field="*{username}" readonly
                   class="w-full px-4 py-3 rounded-lg bg-gray-100 text-gray-700 border border-gray-300 cursor-not-allowed text-sm">
        </div>

        <!-- 邮箱（只读） -->
        <div>
            <label for="email" class="block text-gray-700 font-medium mb-2">邮箱</label>
            <input type="email" id="email" th:field="*{email}" readonly
                   class="w-full px-4 py-3 rounded-lg bg-gray-100 text-gray-700 border border-gray-300 cursor-not-allowed text-sm">
        </div>

        <!-- 公司名称 -->
        <div>
            <label for="company" class="block text-gray-700 font-medium mb-2">公司名称</label>
            <input type="text" id="company" th:field="*{company}" placeholder="请输入公司名称" required
                   class="w-full px-4 py-3 rounded-lg border border-gray-300 text-sm focus:ring-2 focus:ring-blue-300">
            <div th:errors="*{company}" class="text-red-500 text-sm mt-1"></div>
        </div>

        <!-- 联系电话 -->
        <div>
            <label for="phone" class="block text-gray-700 font-medium mb-2">联系电话</label>
            <input type="text" id="phone" th:field="*{phone}" placeholder="请输入联系电话"
                   class="w-full px-4 py-3 rounded-lg border border-gray-300 text-sm focus:ring-2 focus:ring-blue-300">
            <div th:errors="*{phone}" class="text-red-500 text-sm mt-1"></div>
        </div>

        <!-- 公司地址 -->
        <div>
            <label for="address" class="block text-gray-700 font-medium mb-2">公司地址</label>
            <input type="text" id="address" th:field="*{address}" placeholder="请输入公司地址"
                   class="w-full px-4 py-3 rounded-lg border border-gray-300 text-sm focus:ring-2 focus:ring-blue-300">
            <div th:errors="*{address}" class="text-red-500 text-sm mt-1"></div>
        </div>

        <!-- 店铺简介 -->
        <div>
            <label for="description" class="block text-gray-700 font-medium mb-2">店铺简介</label>
            <textarea id="description" th:field="*{description}" placeholder="请输入店铺简介" rows="5"
                      class="w-full px-4 py-3 rounded-lg border border-gray-300 text-sm focus:ring-2 focus:ring-blue-300"></textarea>
            <div th:errors="*{description}" class="text-red-500 text-sm mt-1"></div>
        </div>

        <!-- 店铺 Logo -->
        <div>
            <label for="logoFile" class="block text-gray-700 font-medium mb-2">店铺 Logo（JPG/PNG，可选）</label>
            <input type="file" id="logoFile" name="logoFile"
                   class="block w-full text-sm text-gray-700 file:mr-4 file:py-2 file:px-4 file:rounded-full
                      file:border-0 file:text-sm file:font-semibold file:bg-blue-50 file:text-blue-700 hover:file:bg-blue-100">
            <div th:if="${user.logoUrl}" class="mt-3">

                <p class="text-gray-600">当前 Logo：</p>
                <img th:src="${session.user.avatar ?: '/uploads/placeholder.png'}" alt="店铺 Logo"
                     class="h-20 mt-2 rounded-md shadow">
<!--                <img th:src="${user.logoUrl}" alt="店铺 Logo" class="h-20 mt-2 rounded-md shadow">-->
            </div>
        </div>

        <!-- 营业执照 -->
        <div>
            <label for="licenseFile" class="block text-gray-700 font-medium mb-2">营业执照（PDF，可选）</label>
            <input type="file" id="licenseFile" name="licenseFile"
                   class="block w-full text-sm text-gray-700 file:mr-4 file:py-2 file:px-4 file:rounded-full
                      file:border-0 file:text-sm file:font-semibold file:bg-blue-50 file:text-blue-700 hover:file:bg-blue-100">
            <div th:if="${user.licenseUrl}" class="mt-2">
                <p class="text-gray-600">当前营业执照：<a th:href="${user.licenseUrl}" target="_blank" class="text-blue-600 hover:underline">查看文件</a></p>
            </div>
        </div>

        <!-- 按钮组 -->
        <div class="flex justify-end gap-4 pt-4 border-t border-gray-200">
            <a th:href="@{/supplier/product}"
               class="px-5 py-2 text-sm bg-gray-200 text-gray-700 rounded-md hover:bg-gray-300 transition">
                取消
            </a>
            <button type="submit"
                    class="px-5 py-2 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700 transition shadow">
                保存更改
            </button>
        </div>
    </form>

    </div>
</main>

<!-- 公共底部 -->
<th:block th:replace="~{/footer.html}"></th:block>

<script src="/js/jquery-latest.min.js"></script>
<script src="/js/popper.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
</body>
</html>